package playground;

import cfar.ff.fun.F0;
import cfar.ff.fun.F2;
import java.io.FileInputStream;
import static cfar.ff.fun.Curry.*;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 *
 * @author badi
 */
public class SerializeFun {

    public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
        F2 add = new F2<Integer, Integer, Integer>() {

            public Integer f(Integer a, Integer b) {
                return a + b;
            }
        };

        OutputStream s = new FileOutputStream("/tmp/add2.dat");
        Main.write(curry(curry(add,2),40), s);

        F0 f0 = (F0) Main.read(new FileInputStream("/tmp/42.dat"));
        System.out.println(f0.call());
    }
}
